﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Core.Master" AutoEventWireup="true"
    CodeBehind="LookUpManager.aspx.cs" Title="LookUpManager" Inherits="Pap.Web.Modules.Administration.Views.LookUpManager" %>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
        function btnDelete_Clicked() {
            if (Ext.getCmp('gvTable').hasSelection())
                Ext.Msg.confirm('<asp:Literal runat="server" Text="<%$ Resources:MBConfirmCaption %>" />', '<asp:Literal runat="server" Text="<%$ Resources:MBSureDelete %>" />', Pap.DeleteSelectedEntites);
        }

        function wndValidateForm() {
            return Ext.getCmp('wndMainForm').getForm().isValid();
        }
    </script>

    <ext:Store ID="TableStore" runat="server" AutoLoad="true" OnRefreshData="TableStore_Refresh">
        <Reader>
            <ext:JsonReader ReaderID="ID">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                    <ext:RecordField Name="PID" />
                    <ext:RecordField Name="PName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="ParentTableStore" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="ID">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:FitLayout runat="server">
        <ext:FormPanel ID="pnlMain" runat="server" Border="true" Frame="true" Title="Look Up"
            meta:resourcekey="pnlMainResource1">
            <Body>
                <ext:FitLayout runat="server">
                    <ext:GridPanel ID="gvTable" StoreID="TableStore" runat="server" TrackMouseOver="True"
                        StripeRows="True" IDMode="Static" AutoWidth="True" SelectionSavingBuffer="10">
                        <ColumnModel>
                            <Columns>
                                <ext:Column Header="<%$ Resources:HeaderName %>" DataIndex="Name" Sortable="True" />
                                <ext:Column ColumnID="ParentColumn" Header="Parent" DataIndex="PName" Sortable="true" />
                                <ext:CommandColumn Width="30px" Align="Center" Hideable="False" Sortable="false">
                                    <Commands>
                                        <ext:GridCommand Icon="NoteEdit" CommandName="Edit" IconCls="icon-noteedit">
                                            <ToolTip Text="<%$ Resources:ToolTipEdit %>" />
                                        </ext:GridCommand>
                                    </Commands>
                                </ext:CommandColumn>
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:CheckboxSelectionModel runat="server">
                                <CustomConfig>
                                    <ext:ConfigItem Name="checkOnly" Value="true" Mode="Raw" Encode="False" />
                                </CustomConfig>
                            </ext:CheckboxSelectionModel>
                        </SelectionModel>
                        <TopBar>
                            <ext:Toolbar runat="server" IDMode="Static">
                                <Items>
                                    <ext:Button runat="server" ID="btnAdd" Icon="Add" Text="Add" meta:resourcekey="btnAddResource1">
                                        <AjaxEvents>
                                            <Click OnEvent="btnAdd_Click">
                                                <EventMask ShowMask="true" />
                                            </Click>
                                        </AjaxEvents>
                                    </ext:Button>
                                    <ext:Button runat="server" ID="btnDelete" Icon="Delete" Text="Delete" meta:resourcekey="btnDeleteResource1">
                                        <Listeners>
                                            <Click Handler="btnDelete_Clicked();" />
                                        </Listeners>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <BottomBar>
                            <ext:PagingToolbar ID="tlbrPaging" StoreID="TableStore" runat="server" PageSize="15"
                                DisplayInfo="True" IDMode="Static" meta:resourcekey="tlbrPagingResource1">
                            </ext:PagingToolbar>
                        </BottomBar>
                        <AjaxEvents>
                            <Command OnEvent="gvTable_Command">
                                <ExtraParams>
                                    <ext:Parameter Name="CommandName" Value="command" Mode="Raw" Encode="False" />
                                    <ext:Parameter Name="ID" Value="record.data.ID" Mode="Raw" Encode="False" />
                                    <ext:Parameter Name="Name" Value="record.data.Name" Mode="Raw" Encode="False" />
                                    <ext:Parameter Name="PID" Value="record.data.PID" Mode="Raw" Encode="False" />
                                </ExtraParams>
                            </Command>
                        </AjaxEvents>
                    </ext:GridPanel>
                </ext:FitLayout>
            </Body>
        </ext:FormPanel>
    </ext:FitLayout>
    <ext:Window ID="wndEdit" runat="server" Modal="True" ShowOnLoad="False" Width="400px"
        AutoShow="true" Resizable="False" Closable="False" Constrain="True" AutoHeight="True"
        IDMode="Static" CloseAction="Hide" Collapsible="false" Title="Edit" meta:resourcekey="wndEditResource1">
        <Body>
            <ext:FormPanel ID="wndMainForm" runat="server" meta:resourcekey="wndMainFormResource1"
                AutoWidth="true">
                <Body>
                    <ext:Hidden ID="wndtxtID" runat="server" />
                    <ext:FormLayout ID="kiro" runat="server">
                        <ext:Anchor>
                            <ext:TextField ID="wndtxtName" StyleSpec="width:251px;" runat="server" MaxLength="50"
                                FieldLabel="Name" AllowBlank="False" meta:resourcekey="wndtxtNameResource1" Regex="^[A-zء-ي' ']+$" />
                        </ext:Anchor>
                        <ext:Anchor>
                            <ext:ComboBox ID="cmbParent" StyleSpec="width:251px;" StoreID="ParentTableStore"
                                Editable="true" ForceSelection="true" runat="server" AllowBlank="false" DisplayField="Name"
                                ValueField="ID" meta:resourcekey="cmbParentResource1" TypeAhead="true">
                            </ext:ComboBox>
                        </ext:Anchor>
                    </ext:FormLayout>
                </Body>
                <BottomBar>
                    <ext:StatusBar ID="wndFormStatusBar" runat="server" DefaultText="Ready" meta:resourcekey="wndFormStatusBarResource1">
                        <Plugins>
                            <ext:ValidationStatus ID="wndpnlValidation" FormPanelID="wndMainForm" ValidIcon="Accept"
                                ErrorIcon="Exclamation" runat="server" meta:resourcekey="pnlValidationResource1" />
                        </Plugins>
                        <Items>
                            <ext:Button ID="wndbtnCancel" Text="Cancel" runat="server" Icon="Cancel" meta:resourcekey="wndbtnCancelResource1">
                                <AjaxEvents>
                                    <Click OnEvent="wndbtnCancel_Clicked" />
                                </AjaxEvents>
                            </ext:Button>
                            <quadz:CoolitePermitButton ID="wndbtnSubmit" Text="Submit" runat="server" Icon="Disk"
                                meta:resourcekey="wndbtnSubmitResource1" PermissionName="SaveLookupManager" HideAsDisabled="true">
                                <AjaxEvents>
                                    <Click OnEvent="wndbtnSubmit_Clicked" Before="return wndValidateForm();">
                                        <EventMask ShowMask="true" />
                                    </Click>
                                </AjaxEvents>
                            </quadz:CoolitePermitButton>
                        </Items>
                    </ext:StatusBar>
                </BottomBar>
            </ext:FormPanel>
        </Body>
        <Listeners>
            <Show Handler="#{cmbParent}.syncSize();" />
        </Listeners>
    </ext:Window>
</asp:Content>
